<%DIRECTIVE DYNAMIC;%>

<style type="text/css">
/* 图片上传样式 */
.weui_uploader_input {
	position: absolute;
	z-index: 2;
	top: 30px;
	left: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	-webkit-tap-highlight-color: rgba(0, 0, 0, 0)
}
.weui_uploader_input_wrp {
	float: left;
	position: relative;
	margin-left: 50px;
	width: 70%;
	height: 110px;
	border: 1px solid #d9d9d9
}
.weui_uploader_input_wrp:after, .weui_uploader_input_wrp:before {
	content: " ";
	position: absolute;
	top: 50%;
	left: 50%;
	-webkit-transform: translate(-50%, -50%);
	transform: translate(-50%, -50%);
	background-color: #d9d9d9
}
.weui_uploader_input_wrp:before {
	width: 2px;
	height: 39.5px
}
.weui_uploader_input_wrp:after {
	width: 39.5px;
	height: 2px
}
.weui_uploader_input_wrp:active {
	border-color: #999
}
.weui_uploader_input_wrp:active:after, .weui_uploader_input_wrp:active:before
	{
	background-color: #999
}
</style>
<div class="modal-header">
	<button type="button" class="close" data-dismiss="modal" aria-label="Close">
		<span aria-hidden="true">&times;</span>
	</button>
	<h5 class="modal-title" >修改</h5>
</div>
<form id="eidtForm" role="form" class="form-horizontal parsley-form" data-parsley-validate action="${base}/platform/fieldTrue/editDo" method="post">
	<div class="modal-body ">
		<input type="hidden" name="id" value="${obj.field.id!}">
	   	<input type="hidden" name="lng" value="${obj.field.lng!}">
	   	<input type="hidden" name="lat" value="${obj.field.lat!}">
	   	<input type="hidden" name="type" value="${obj.field.type!}">
		<input type="hidden" name="deleteIds" id="deleteIds" value="">
	    <div class="row mb10">
	    	<div class="col-lg-12">
	       		<div class="form-group">
	           		<label for="name" class="col-sm-2 control-label">名称</label>
	             	<div class="col-sm-8">
	             		<input type="text" id="name" value="${obj.field.name!}" class="form-control" name="name"  required="required" placeholder="名称">
	                </div>
	          	</div>
	            <div class="form-group">
	           		<label for="tel" class="col-sm-2 control-label">电话</label>
					<div class="col-sm-8">
	            		<input type="text" id="tel" name="tel" value="${obj.field.tel!}" required="required" class="form-control" placeholder="电话">
	                </div>
	     		</div>
	         	<div class="form-group">
	         		<label for="lnglat" class="col-sm-2 control-label">经纬度</label>
	             	<div class="col-sm-8">
	              		<input type="text" id="lnglat" readonly="readonly" value="${obj.field.lng!},${obj.field.lat!}" required="required" class="form-control" placeholder="经纬度">
	             	</div>
	           	</div>
	        	<div class="form-group">
	             	<label for="address" class="col-sm-2 control-label">地址</label>
                   	<div class="col-sm-8">
                 		<input type="text" id="address" name="address" value="${obj.field.address!}" required="required" class="form-control" placeholder="地址">
                   	</div>
              	</div>
         	</div>
      	</div>
     	<div class="row mb12">
			<div style="clear:both;margin:10px 0;" id="photoDiv"  class="col-sm-10">
				<% if(null != obj.photo_list){ for(o in obj.photo_list){ if(null!=o.url ){%>
					<div style="margin-left: 150px;">
						<div style="float: left; width: 150px; height: 150px">
							<img style="width: 150px; height: 150px" alt="" src="${o.url!}" >
							<span style="position: relative; left: 123px; top:-145px; z-index: 10;">
								<img src="${base!}/assets/img/del.png" onclick="delold(this,'${o.id!}')" style="width:20px;height: 20px"/>
							</span>
						</div>
					</div>
				<%}}}%>
			</div>
			<div id="btnUpload" style="margin-left: 116px; margin-top: 8px;" >
				<div class="weui_uploader_input_wrp">
					<input id="one" type="file" class="weui_uploader_input accept="image/jpg,image/jpeg,image/png,image/gif" multiple="">
				</div>
			</div>
		</div>
	</div>
	<div class="modal-footer">
		<button  class="btn btn-default btn-sm btn-parsley"  >完成</button> 
	</div>
</form>
<script language="JavaScript">
    $(function() { 
	   upload();
	});
	//图片上传
	var i = 0;
	function upload() {
		$('#one').change(
		function() {
			i++;
			var file = this.files[0];
			var r = new FileReader();
			r.readAsDataURL(file);
			$(r).load(function() {
			var html = '<div style="margin-left: 150px;">'+
						'<div style="float: left; width: 150px; height: 150px">'
						+ '<input type="hidden" name="title['+i+']"  value=""  />'
						+ '<input type="hidden" name="url['+i+']" value="'+ this.result.replace(",", ".")+ '" />'
						+ '<img alt="" src="'+this.result +'" style="width: 150px; height: 150px" >'
						+ '<span style="position: relative; left: 123px; top:-145px; z-index: 10;">'
						+ '<img src="${base!}/assets/img/del.png" onclick="delold(this)" style="width:20px;height: 20px"/>'
						+ '</span></div></div>';
						$("#photoDiv").append(html);
			})
		})
	}
  	//删除原有图片
	function delold(obj,id){
		var ids=$("#deleteIds").val();
		ids=ids+";"+id;
		$("#deleteIds").val(ids);
		jQuery(obj).parent().parent().remove();
	}
</script>

